package world.ztomorrow.novel.listen;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import world.ztomorrow.common.dto.RestResp;
import world.ztomorrow.common.utils.UserHolder;
import world.ztomorrow.novel.dto.req.UserCommentReqDto;
import world.ztomorrow.novel.service.BookService;

@RestController
@RequiredArgsConstructor
public class CommentListen {

    private final BookService bookService;

    @PostMapping("/comment")
    RestResp<Void> saveComment(@RequestBody UserCommentReqDto dto){
        return bookService.saveComment(dto);
    }

    @PutMapping("/comment/{id}")
    RestResp<Void> updateComment(@PathVariable Long id,
                       @RequestBody String content){
        return bookService.updateComment(UserHolder.getUserId(), id, content);
    }

    @DeleteMapping("/comment/{id}")
    RestResp<Void> deleteComment(@PathVariable Long id){
        return bookService.deleteComment(UserHolder.getUserId(), id);
    }
}
